package util;

import java.awt.Color;
import java.awt.Component;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
  
/** 
* @author Uelinton 
*/  
public class ColorRowRenderer extends DefaultTableCellRenderer {        
     
    @Override  
    public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected,   
                                                    boolean hasFocus, int row, int column ) {        
       
        JLabel label = (JLabel) super.getTableCellRendererComponent( table, value, isSelected, 
                                                                     hasFocus, row, column);
        
        if (isSelected){
            label.setBackground(table.getSelectionBackground());
        } else {
            if (row % 2 == 1){
                label.setBackground(new Color(217,230,245));                
            } else {
                label.setBackground(new Color(255,255,255));
            }
        }     
      
      return label;
   }         
    
      
}  
